package com.xcc.pay.controller;

import com.xcc.entities.CommonResult;
import com.xcc.entities.Payment;
import com.xcc.pay.service.PaymentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class PaymentController {

    @Autowired
    PaymentService paymentService;

    @PostMapping("/save")
    public CommonResult save(@RequestBody Payment payment) {
        int insert = paymentService.insert(payment);
        if (insert >0) {
            return new CommonResult(200, "插入成功，Serverport为8002",payment);
        }else {
            return new CommonResult(505, "插入失败");
        }
    }

    @GetMapping("/getById/{id}")
    public CommonResult<Payment> getById(@PathVariable Long id) {
        Payment payment = paymentService.getById(id);
        if (payment != null) {
            return new CommonResult(200, "查询成功，Serverport为8002",payment);
        }else {
            return new CommonResult(505, "查询失败");
        }
    }

}
